/*
 * Home.java
 *
 * Created on January 29, 2007, 11:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ge.info.pages;

import ge.info.domain.MainResult;
import ge.info.domain.MainResultDetail;
import ge.info.domain.Service;
import ge.ktapestry.pages.BasePageExt;
import org.apache.hivemind.util.PropertyUtils;
import org.apache.tapestry.IPage;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.Persist;

import java.util.List;

public  abstract class MainResults extends BasePageExt
{
    
    @Persist
    public abstract Service getService();
    public abstract void setService(Service service);    
    
    @Persist("session")
    public abstract List<MainResult> getMainResults();
    public abstract void setMainResults(List<MainResult> mainResults);
    
    public abstract MainResult getMainResult();
    public abstract void setMainResult(MainResult mainResult);
    
    private MainResultDetail detail;

    
    public void openMainResultPage(IRequestCycle cycle, MainResult result)
    {
        if (getMainResults().size() > 1)
        {
            getDbExecutor().logMainResult(result.getMainID(),getSession(),getService());
            
        }
        getDbExecutor().getMainResultDetails(result, getSession());
        IPage page = cycle.getPage("MainResultPage");
        PropertyUtils.write(page,"mainResult",result);
        cycle.activate(page);
    }

    public MainResultDetail getDetail()
    {
        return detail;
    }

    public void setDetail(MainResultDetail detail)
    {
        this.detail = detail;
    }


}
